#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    char arr[1001] = { 0 };
    scanf("%s", arr);
    int maxi = 0, mini = 0, count[27] = { 0 };
    for (int i = 0; i < strlen(arr); i++)
    {
        count[arr[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)
    {
        if (count[i] != 0)
        {
            if (count[i] > count[maxi])
            {
                maxi = i;
            }
            if (count[i] < count[mini])
            {
                mini = i;
            }
        }
    }
    printf("%d\n", count[maxi] - count[mini]);
    return 0;
}